<%@page import="org.jeecgframework.web.util.StaticValue"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery"></t:base>
<head>
    <script type="text/javascript" src="plug-in/jquery/jquery-1.8.3.js"></script>
    <script type="text/javascript" src="plug-in/tools/curdtools_zh-cn.js"></script>
    <script type="text/javascript" src="plug-in/Highcharts-4.2.4/highcharts.js" ></script>
    <script type="text/javascript" src="plug-in/easyui/jquery.easyui.min.1.3.2.js"></script>
    <script type="text/javascript" src="plug-in/lhgDialog/lhgdialog.min.js"></script>
    <script type="text/javascript" src="plug-in/My97DatePicker/WdatePicker.js"></script>
    <link rel="stylesheet" href="plug-in/easyui/themes/default/easyui.css" type="text/css"></link>
    <link rel="stylesheet" href="plug-in/easyui/themes/icon.css" type="text/css"></link>
    <link rel="stylesheet" href="plug-in/tools/css/common.css" type="text/css"></link>
<html>
<script>
    var raData = {};
    $(function () {
        /*Gross-SL1*/
        initallTpHighChartsOfLine(raData);
        /*NET-SL1*/
        initallTpHighChartsOfLine2(raData);
        /*Gross-SL2*/
        initallTpHighChartsOfLine3(raData);
        /*NET-SL2*/
        initallTpHighChartsOfLine4(raData);
    });

    /*Gross-SL1*/
    function StatisticalShipment(raData) {
       var month =  raData.month ;
       var week =  raData.week ;
        var startTime = raData.startTime ;
        var endTime = raData.endTime;
        var temp = raData.temp;
        var data;
        $.ajax({
            type:"post",
            dataType:"json",
            async : false,
            data:{"type":"Gross","slaType":"SL1","month":month,"week":week,"startTime":startTime,"endTime":endTime,"temp":temp},
            url:"cbsDelinerController.do?toStatisticalShipment",
            success:function (result) {
                data = result;
            }
        })
        return data;
    }
    /*Gross-SL2*/
    function StatisticalShipment2(raData) {
        var month =  raData.month ;
        var week =  raData.week ;
        var startTime = raData.startTime ;
        var endTime = raData.endTime;
        var temp = raData.temp;
        var data;
        $.ajax({
            type:"post",
            dataType:"json",
            async : false,
            data:{"type":"Gross","slaType":"SL2","month":month,"week":week,"startTime":startTime,"endTime":endTime,"temp":temp},
            url:"cbsDelinerController.do?toStatisticalShipment",
            success:function (result) {
                data = result;
            }
        })
        return data;
    }
    /*Net-SL1*/
    function StatisticalShipment3(raData) {
        var month =  raData.month ;
        var week =  raData.week ;
        var startTime = raData.startTime ;
        var endTime = raData.endTime;
        var temp = raData.temp;
        var data;
        $.ajax({
            type:"post",
            dataType:"json",
            async : false,
            data:{type: "Net", "slaType":"SL1","month":month,"week":week,"startTime":startTime,"endTime":endTime,"temp":temp},
            url:"cbsDelinerController.do?getSl2Percentage",
            success:function (result) {
                data = result;
            }
        })
        return data;
    }
    /*Net-SL2*/
    function StatisticalShipment4(raData) {
        var month =  raData.month ;
        var week =  raData.week ;
        var startTime = raData.startTime ;
        var endTime = raData.endTime;
        var temp = raData.temp;
        var data;
        $.ajax({
            type:"post",
            dataType:"json",
            async : false,
            data:{"type":"Net","slaType":"SL2","month":month,"week":week,"startTime":startTime,"endTime":endTime,"temp":temp},
            url:"cbsDelinerController.do?getSl2Percentage",
            success:function (result) {
                data = result;
            }
        })
        return data;
    }
    function calculationRow(data){
        var rowData = {};
        var countArr = new Array();
        var monthArr = new Array();

        for(var k in data.data){
            var months = [];
            var mapValue=data.data[k]
            for(var l in mapValue){
                var dataValue=mapValue[l]
                countArr.push(dataValue);
                months.push(l)
            }
            monthArr.push(months)
        }
        rowData.name = data.name;
        rowData.data = countArr;
        rowData.month=monthArr;
        return rowData;
    }
    function toPercent(num) {

            return (Math.round(num * 10000)/100).toFixed(2) + '%';

    }
    function exReport() {
        var startTime = $("#startTime").val();
        var endTime = $("#endTime").val();
        myDownload("cbsDelinerController.do?exReportCbsDeliver&startTime="+startTime+"&endTime="+endTime);
    }
    function searchReport() {
        raData.temp="";
        var month =  $("#month").val();
        var week = $("#week").val();
        if(month!=''&&week!=''){
            tip("月报与周报不能同时选择!");
            return false;
        }
        var startTime = $("#startTime").val();
        var endTime = $("#endTime").val();
        if(startTime!=''&&month!='' || month!=''&&endTime!='' ){
            tip("发货时间与月报不能同时选择!");
            return false;
        }
        if(startTime!=''&&week!='' || week!=''&&endTime!='' ){
            tip("发货时间与周报不能同时选择!");
            return false;
        }
        raData.month  = month;
        raData.week  = week;
        raData.startTime  = startTime;
        raData.endTime  = endTime;
        if (month != ''){
            raData.temp = "hav";
        }
        if (startTime != '' && endTime!=''){
            raData.temp = "hav";
        }
        if (week != '' ){
            raData.temp = "hav";
        }
        /*Gross-SL1*/
        initallTpHighChartsOfLine(raData);
        /*NET-SL1*/
        initallTpHighChartsOfLine2(raData);
        /*Gross-SL2*/
        initallTpHighChartsOfLine3(raData);
        /*NET-SL2*/
        initallTpHighChartsOfLine4(raData)
    }
    /*NET-SL1*/
    function initallTpHighChartsOfLine2(raData) {
        var data  = StatisticalShipment3(raData);
        var dataArr = new Array();
        $(data).each(function(i,item){
            var rowData = calculationRow(data[i]);
            dataArr.push(rowData);
        });
        $("#report2").highcharts({
            credits: {//去水印
                text: '',
                href: ''
            },
            title: {
                text: 'NET-SL1',
                x: -20 //center
            },
            tooltip: {
                formatter: function () {
                    var num = this.point.y *100;
                    var  s = '<span>' + this.point.series.name + ': ' +
                        num.toFixed(2) + '%' + ' </span>';
                    return s;
                }
            },
            xAxis: {
                categories: dataArr[0].month
            },
            yAxis: {
                title: {
                    text: ''
                },
                max: 1,
                min: 0,
                labels:{
                    formatter:function () {
                        return this.value*100+"%";
                    }
                },
            },
            series : dataArr
        });
    }
    /*Gross-SL1*/
    function initallTpHighChartsOfLine(raData) {
        var data = StatisticalShipment(raData);
        var dataArr = new Array();
        $(data).each(function(i,item){
            var rowData = calculationRow(data[i]);
            dataArr.push(rowData);
        });
        $("#report1").highcharts({
            credits: {//去水印
                text: '',
                href: ''
            },
            title: {
                text: 'Gross-SL1',
                x: -20 //center
            },
            tooltip: {
                formatter: function () {
                    var num = this.point.y *100;
                   var  s = '<span>' + this.point.series.name + ': ' +
                       num.toFixed(2) + '%' + ' </span>';
                       return s;
                }
            },
            xAxis: {
                categories: dataArr[0].month
            },
            yAxis: {
                title: {
                    text: ''
                },
                max: 1,
                min: 0,
                labels:{
                    formatter:function () {
                        return this.value*100+"%";
                    }
                }
            },
            series : dataArr
        });


    }
    /*Gross-SL2*/
    function initallTpHighChartsOfLine3(raData) {
        var data = StatisticalShipment2(raData);
        var dataArr = new Array();
        $(data).each(function(i,item){
            var rowData = calculationRow(data[i]);
            dataArr.push(rowData);
        });
        $("#report3").highcharts({

            credits: {//去水印
                text: '',
                href: ''
            },
            title: {
                text: 'Gross-SL2',
                x: -20 //center
            },
            tooltip: {
                formatter: function () {
                    var num = this.point.y *100;
                    var  s = '<span>' + this.point.series.name + ': ' +
                        num.toFixed(2) + '%' + ' </span>';
                    return s;
                }
            },
            xAxis: {
                categories: dataArr[0].month
            },
            yAxis: {
                title: {
                    text: ''
                },
                max: 1,
                min: 0,
                labels:{
                    formatter:function () {
                        return this.value*100+"%";
                    }
                }
            },
            series : dataArr
        });
    }
    /*NET-SL2*/
    function initallTpHighChartsOfLine4(raData) {
        var data = StatisticalShipment4(raData);
        var dataArr = new Array();
        $(data).each(function(i,item){
            var rowData = calculationRow(data[i]);
            dataArr.push(rowData);
        });
        $("#report4").highcharts({

            credits: {//去水印
                text: '',
                href: ''
            },
            title: {
                text: 'Net-SL2',
                x: -20 //center
            },
            tooltip: {
                formatter: function () {
                    var num = this.point.y *100;
                    var  s = '<span>' + this.point.series.name + ': ' +
                        num.toFixed(2) + '%' + ' </span>';
                    return s;
                }
            },
            xAxis: {
                categories: dataArr[0].month
            },
            yAxis: {
                title: {
                    text: ''
                },
                max: 1,
                min: 0,
                labels:{
                    formatter:function () {
                        return this.value*100+"%";
                    }
                }
            },
            series : dataArr
        });
    }
</script>
<head>
    <title>物流发货报表</title>
</head>
<body style="padding: 0px;margin: 0px auto;overflow-x: hidden;">
<div class="report_title">物流发货报表</div>
    <table width="100%">
        <tr>
            <td>
                <label class="report_label">通知发货时间:</label>
                <input class="Wdate" style="width: 110px" id="startTime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd '})" />～
                <input class="Wdate" style="width: 110px" id="endTime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd '})"/>

            </td>
            <td>
                <label class="report_label">周报:</label>
                <select  id="week">
                    <option value="">请选择</option>
                    <option value="1">第一周</option>
                    <option value="2">第二周</option>
                    <option value="3">第三周</option>
                    <option value="4">第四周</option>
                    <option value="5">第五周</option>
                    <option value="6">第六周</option>
                    <option value="7">第七周</option>
                    <option value="8">第八周</option>
                    <option value="9">第九周</option>
                    <option value="10">第十周</option>
                    <option value="11">第十一周</option>
                    <option value="12">第十二周</option>
                    <option value="13">第十三周</option>
                    <option value="14">第十四周</option>
                    <option value="15">第十五周</option>
                    <option value="16">第十六周</option>
                    <option value="17">第十七周</option>
                    <option value="18">第十八周</option>
                    <option value="19">第十九周</option>
                    <option value="20">第二十周</option>
                    <option value="21">第二一周</option>
                    <option value="22">第二十二周</option>
                    <option value="23">第二十三周</option>
                    <option value="24">第二十四周</option>
                    <option value="25">第二十五周</option>
                    <option value="26">第二十六周</option>
                    <option value="27">第二十七周</option>
                    <option value="28">第二十八周</option>
                    <option value="29">第二十九周</option>
                    <option value="30">第三十周</option>
                    <option value="31">第三十一周</option>
                    <option value="32">第三十二周</option>
                    <option value="33">第三十三周</option>
                    <option value="34">第三十四周</option>
                    <option value="35">第三十五周</option>
                    <option value="36">第三十六周</option>
                    <option value="37">第三十七周</option>
                    <option value="38">第三十八周</option>
                    <option value="39">第三十九周</option>
                    <option value="40">第四十周</option>
                    <option value="41">第四十一周</option>
                    <option value="42">第四十二周</option>
                    <option value="43">第四十三周</option>
                    <option value="44">第四十四周</option>
                    <option value="45">第四十五周</option>
                    <option value="46">第四十六周</option>
                    <option value="47">第四十七周</option>
                    <option value="48">第四十八周</option>
                    <option value="49">第四十九周</option>
                    <option value="50">第五十周</option>
                    <option value="51">第五十一周</option>
                    <option value="52">第五十二周</option>
                </select>
            </td>
            <td>
                <label class="report_label">月报:</label>
                <select id="month">
                    <option value="">--请选择月份--</option>
                    <option value="01">1月</option>
                    <option value="02">2月</option>
                    <option value="03">3月</option>
                    <option value="04">4月</option>
                    <option value="05">5月</option>
                    <option value="06">6月</option>
                    <option value="07">7月</option>
                    <option value="08">8月</option>
                    <option value="09">9月</option>
                    <option value="10">10月</option>
                    <option value="11">11月</option>
                    <option value="12">12月</option>
                </select>
            </td>
            <td>
                <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="searchReport()">查询</a>
            </td>
            <td>
                <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-putout',plain:'true'" onclick="exReport()">导出报告</a>
            </td>
        </tr>

    </table>

    <div id="report1" style="width: 46%;height:400px;display: inline-block;"></div>
    <div id="report2" style="width: 46%;height:400px;display: inline-block; "></div>
    <div id="report3" style="width: 46%;height:400px;display: inline-block;"></div>
    <div id="report4" style="width: 46%;height:400px;display: inline-block;"></div>

</div>

</body>
</html>
